<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>定时器方法</title>
</head>
<body>
<h1>setTimeout(fn,delay):在达到指定时间后调用函数或执行一段代码</h1>
<h1>setInterval(fn,delay):按照指定的周期来调用函数或执行一段代码</h1>
<h1>clearTimeout():清除由timeout设置的定时器</h1>
<h1>clearInterval():清除由setInterval设置的定时器</h1>

<script>
  function ed(){
    console.log('ed')
  }
  function ed2(){
    console.log('ed2')
  }
 var timer=setTimeout(ed,2000);
 var timer2=setInterval(ed2,500);
 clearTimeout(timer);
 clearInterval(timer2);
</script>
</body>
</html>